package test;

/**
 * @program: test-idea
 * @description: dead lock and jstack #pid
 * @author: Keyu Li
 * @create: 2021-10-07 23:17
 **/

public class DeadLock {
    static A a = new A();
    static B b = new B();

    public static void main(String[] args) {
        new Thread(()->{
            synchronized (a){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (b){
                    System.out.println("get lock b");
                }
            }
        }).start();

        new Thread(()->{
            synchronized (b){
                synchronized (a){
                    System.out.println("get lock a");
                }
            }
        }).start();
    }
}

class A{

}

class B{

}